package com.sk.imitationnetease.model

import android.os.Parcel
import android.os.Parcelable
import com.sk.imitationnetease.base.BaseResponse

class SongList() : BaseResponse<SongList>(),Parcelable {
    var songs: MutableList<Song> = mutableListOf()
    var hasMore: Boolean = false
    var songCount: Int = 0

    constructor(parcel: Parcel) : this() {
        hasMore = parcel.readByte() != 0.toByte()
        songCount = parcel.readInt()
    }

    class Song {
        var id: Int = 0
        var name: String = ""
        var artists: MutableList<Artist> = mutableListOf()
        var album: Album = Album()
        var duration: Int = 0
        var copyrightId: Int = 0
        var status: Int = 0
        var alias: LinkedHashMap<String, String> = linkedMapOf()
        var rtype: Int = 0
        var ftype: Int = 0
        var mvid: Int = 0
        var fee: Int = 0
        var rUrl: String = ""
        var mark: Int = 0
    }

    class Artist {
        var id: Int = 0
        var name: String = ""
        var picUrl: String = ""
        var alias: LinkedHashMap<String, String> = linkedMapOf()
        var albumSize: Int = 0
        var picId: Int = 0
        var img1v1Url: String = ""
        var img1v1: String = ""
        var trans: String = ""
    }

    class Album {
        var id: Int = 0
        var name: String = ""
        var artist: Artist = Artist()
        var publishTime: Long = 0L
        var size: Int = 0
        var copyrightId: Int = 0
        var status: Int = 0
        var picId: Long = 0L
        var mark: Int = 0
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeByte(if (hasMore) 1 else 0)
        parcel.writeInt(songCount)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<SongList> {
        override fun createFromParcel(parcel: Parcel): SongList {
            return SongList(parcel)
        }

        override fun newArray(size: Int): Array<SongList?> {
            return arrayOfNulls(size)
        }
    }
}